﻿using B.S.DataBase.MyProject.Domain.DiagnosisAndTreatmentManagement;
using B.S.DataBase.MyProject.Domain.Management;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using MedicalPCTerminal.Read.API.Appcation.Commands.Management;
using MedicalPCTerminal.Read.API.Dtos;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace MedicalPCTerminal.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ManagementController : ControllerBase
    {
        /// <summary>
        /// 日志
        /// </summary>
        private readonly ILogger<ManagementController> logger;
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="logger">日志</param>
        /// <param name="mediator">中介者</param>
        public ManagementController(ILogger<ManagementController> logger,IMediator mediator)
        {
            this.logger = logger;
            this.mediator = mediator;
        }
        /// <summary>
        /// 查询健康报告
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiPaging<NewReportsDto>> GetReports([FromQuery] GetReportsCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request, cancellationToken);
        }
        [HttpGet]
        public async Task<APIResult<CollectionManagement>> GetBool([FromQuery]GetBoolCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return await mediator.Send(request);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询随访管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<ApiPaging<Basic>>> GetBasic([FromQuery]GetBasicCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
        /// <summary>
        /// 已随访列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<ApiPaging<Basic>>> GetBasicFollow([FromQuery]GetBasicFollowCommand request, CancellationToken cancellationToken)
        {
            try
            {
                return mediator.Send(request, cancellationToken);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 根据随访ID查询随访详情
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<object>> GetFollow([FromQuery]GetFollowCommand request, CancellationToken cancellationToken)
        {
            return mediator.Send(request, cancellationToken);
        }
    }
}
